﻿using Darius.API.Application.Commands.Approval;
using IMES.Common.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Darius.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ApprovalController : ControllerBase
    {
        private readonly IMediator mediator;

        public ApprovalController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 审批添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddApproval(ApprovalCreateCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 审批查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> ShowApproval(ApprovalSearchCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 审批更新
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<Result> UpdateApproval(ApprovalUpdateCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
    
}
